import java.util.Enumeration;
import java.util.Properties;
import java.util.Set;

public class PropertiesTest {
    public static void main(String[] args) {
        Properties p=new Properties();
        //设置属性
        p.setProperty("admin1","value1");
        System.out.println(p);
        //获取属性
        String v=p.getProperty("admin1");
        System.out.println("admin1="+v);
        System.out.println(p.getProperty("admin","默认"));

        {
            Enumeration<?> names=p.propertyNames();
            while (names.hasMoreElements()){
                String name=(String) names.nextElement();
                System.out.println(name+"="+p.getProperty(name));
            }
        }
        {
            System.out.println("-----------------------");
            Set<String> names=p.stringPropertyNames();
            for(String name : names) {
                System.out.println(name + "=" + p.getProperty(name));
            }

        }
    }
}
